﻿// <copyright file="IOC.cs" company="DatamineConsulting">
//      Copyright (c) DatamineConsulting.  All rights reserved.
// </copyright>
// <author>Sites, Ryan</author>

namespace Kanz4Kidz.Common
{
    using Microsoft.Practices.Unity;

    /// <summary>
    /// The implementation of a ioc.
    /// </summary>
    public static class Ioc
    {
        #region declarations

        /// <summary>
        /// Stores a reference to the lock object.
        /// </summary>
        private static readonly object LockObj = new object();

        /// <summary>
        /// Stores a reference to the _container.
        /// </summary>
        private static volatile IUnityContainer container;

        #endregion //declarations

        #region properties

        /// <summary>
        /// Gets the container.
        /// </summary>
        public static IUnityContainer Container
        {
            get
            {
                if (container == null)
                {
                    lock (LockObj)
                    {
                        if (container == null)
                        {
                            IUnityContainer tempContainer = new UnityContainer();
                            container = tempContainer;
                        }
                    }
                }

                return container;
            }
        }

        #endregion //properties
    }
}
